// 加密
function do_encrypt(key, plain) {

	var ctext = "";
	// do the encoding
	for(var i = 0; i < plain.length; i++) {
		var pcode = plain.charCodeAt(i);
		var ccode = pcode;
		if(pcode >= 65 && pcode <= 90) {
			ccode = ((pcode - 65) + key * 1) % 26 + 65;
		}
		if(pcode >= 97 && pcode <= 122) {
			ccode = ((pcode - 97) + key * 1) % 26 + 97;
		}
		// console.log(pcode + "," + ccode);
		ctext += String.fromCharCode(ccode);
	}
	return ctext;
	console.log(ctext);
}
// 解密
function do_decrypt(key, ctext) {
	var plain = "";
	// do the encoding
	for(var i = 0; i < ctext.length; i++) {
		var ccode = ctext.charCodeAt(i);
		var pcode = ccode;
		if(ccode >= 65 && ccode <= 90) {
			pcode = ((ccode - 65) - key * 1 + 26) % 26 + 65;
		}
		if(ccode >= 97 && ccode <= 122) {
			pcode = ((ccode - 97) - key * 1 + 26) % 26 + 97;
		}
		// console.log(ccode + "," + pcode);
		plain += String.fromCharCode(pcode);
	}
	// console.log(-3 % 26);

	return plain;
}